import Room, Defines

class Base():
	def __init__(self):
		self.Cave = []
		for i in range(0, Defines.FLOORNUM):
			self.floor = []
			for j in range(0, Defines.ROOMNUM):
				self.floor.append(Room.Room(i,j))
			self.Cave.append(self.floor)

		self.moneyCounter = 1
		self.scienceCounter = 0
		self.powerCounter = 2
		self.medBayCounter = 1
		self.y_Pos = 0
		self.x_Pos = 0

		self.money = 1000
		self.science = 100
		self.power = 100

	def changeRoom(self, x_Pos, y_Pos):
		for event in pygame.event.get(): # event handling loop
			while event.type != KEYDOWN:
				if event.type == QUIT:
					terminate()
			if event.type == KEYDOWN:
				if(event.key == K_m):
					room[x_Pos, y_Pos].type = Defines.RoomType.MONEY
					self.moneyCounter += 1
					return true
				if(event.key == K_s):
					room[x_Pos, y_Pos].type = Defines.RoomType.SCIENCE
					self.scienceCounter += 1
					return true
				if(event.key == K_p):
					room[x_Pos, y_Pos].type = Defines.RoomType.POWER
					self.powerCounter += 1
					return true
				if(event.key == K_h):
					room[x_Pos, y_Pos].type = Defines.RoomType.MED_BAYS
					self.medBayCounter += 1
					return true
		return false

	def selectRoom(self):
		for event in pygame.event.get(): # event handling loop
		#output message saying available positions
			if event.type == KEYDOWN:
				if (event.key == K_UP):
					self.y_Pos += 1
				elif (event.key == K_DOWN):
					self.y_Pos -= 1
				elif (event.key == K_LEFT):
					self.x_Pos -= 1
				elif (event.key == K_RIGHT):
					self.x_Pos += 1
				if (event.key == K_ENTER):
					self.Base.ChangeRoom(x_Pos, y_Pos)
					return true
		return false

	def GetRoomType(self, x_Pos, y_Pos):
		return self.Cave[x_Pos][y_Pos].type



